export function WatchFile(file) {
	
	let e = file;
	if (e.substring(e.length - 3) == "png" || e.substring(e.length - 3) == "jpg" || e.substring(e.length -
			3) == "jpeg") {
		uni.previewImage({
			urls: [e],
			longPressActions: {
				itemList: ['暂无操作'],
				success: function(data) {
					// console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
				},
				fail: function(err) {
					// console.log(err.errMsg);
				}
			},
			showmenu: false
		})

	} else if (e.substring(e.length - 3) == "pdf" || e.substring(e.length - 3) == "PDF") {
	

		// #ifdef MP-WEIXIN
		uni.getSystemInfo({
			success: res => {
				console.log(res.platform);
				if (res.platform === 'android') {
					uni.showLoading({
						title: '请稍后...'
					})
					wx.downloadFile({
						url: e,
						success: function(res) {
							const filePath = res.tempFilePath;
							wx.openDocument({
								filePath: filePath,
								fileType: 'pdf',
								showMenu: false,
								success: function(res) {
									console.log('打开文档成功');
								}
							});
						},
						complete() {
							uni.hideLoading();
						}
					});
				} else {
					// this.url = this.fileUrl;
					uni.navigateTo({
						url: '/pagesNotLogin/webview/webview?pdfUrl=' + encodeURIComponent(
							e)
					});
				}
			}
		});
		// #endif

		// #ifdef APP-PLUS
		uni.navigateTo({
			url: '/pagesNotLogin/webview/webview?pdfUrl=' + encodeURIComponent(e)
		})
		// #endif



	} else {
		uni.showLoading({
			title: '请稍后...'
		})
		wx.downloadFile({
			url: e,
			success: function(res) {
				const filePath = res.tempFilePath;
				wx.openDocument({
					filePath: filePath,
					showMenu: false,
					success: function(res) {
						console.log('打开文档成功');
					}
				});
			},
			complete() {
				uni.hideLoading();
			}
		});
		// uni.showToast({
		// 	title: e.substring(e.length - 3) + '文件格式不支持',
		// 	icon: 'none'
		// });
		
	}
}